﻿using DeviceMaintainGIS.Entity;
using DeviceMaintainGIS.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DeviceMaintainGIS.BLL.GIS
{
    /// <summary>
    /// 地图操作
    /// </summary>
    public class GISService
    {
        /// <summary>
        /// 获取地图上的基站 项目 信息
        /// </summary>
        /// <returns></returns>
        public ReturnListVM<GISModel> GetGISInfoList()
        {
            ReturnListVM<GISModel> list = new ReturnListVM<GISModel>();
            using (CYOADBEntities Entities = new CYOADBEntities())
            {
                //基站信息
                var LocaLinq = from a in Entities.LocaInfo_Tab
                               select new GISModel
                               {
                                   ID = a.LocaId,
                                   Name = a.LocaName,
                                   Type = 0,
                                   Latitude = a.Latitude,
                                   Longitude = a.Longitude
                               };
                List<GISModel> LocaList = LocaLinq.ToList();
                //项目信息
                var ProInfoLinq = from a in Entities.ProInfo_Tab.Where(i => i.Latitude != null)
                                  select new GISModel
                                  {
                                      ID = a.ProjectGuid,
                                      Name = a.ProjectName,
                                      Type = 1,
                                      Latitude = a.Latitude,
                                      Longitude = a.Longitude
                                  };
                List<GISModel> ProList = ProInfoLinq.ToList();
                LocaList.AddRange(ProList);
                list.List = LocaList;
            }
            return list;
        }
    }
}
